package com.loadmore.common.skin

import android.os.Bundle
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.loadmore.common.R
import com.loadmore.common.base.BaseFragment
import com.loadmore.common.router.RouterPath
import kotlinx.android.synthetic.main.fragment_skin.*
import skin.support.SkinCompatManager


@Route(path = RouterPath.Skin)
class SkinFragment : BaseFragment() {
    override fun getLayoutId(): Int {
        return R.layout.fragment_skin
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        skin_1.setOnClickListener {

            changeSkin(1)
        }

        skin_2.setOnClickListener {

            changeSkin(2)
        }
    }
    private fun changeSkin(style:Int) {
        when(style) {
            1-> SkinCompatManager.getInstance().loadSkin("one.skin", null, SkinCompatManager.SKIN_LOADER_STRATEGY_ASSETS)

            2-> SkinCompatManager.getInstance().loadSkin("two.skin", null, SkinCompatManager.SKIN_LOADER_STRATEGY_ASSETS)

            3-> SkinCompatManager.getInstance().loadSkin("one.skin", null, SkinCompatManager.SKIN_LOADER_STRATEGY_ASSETS)
        }

    }
}